package sku

import (
	"context"
	"mall/services/product/rpc/internal/mapper"

	"mall/services/product/rpc/internal/svc"
	"mall/services/product/rpc/pb"

	"github.com/zeromicro/go-zero/core/logx"
)

type DelSkuAttrLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDelSkuAttrLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DelSkuAttrLogic {
	return &DelSkuAttrLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *DelSkuAttrLogic) DelSkuAttr(in *pb.DelSkuAttrDTO) (*pb.EmptyObj, error) {
	// del att value ...
	valueMapper := mapper.NewSpuSkuAttrValueMapper()
	deleteErr := valueMapper.DeleteCtx(l.ctx, l.svcCtx.DBEngin, in.SpuSkuAttrValueId)
	if deleteErr != nil {
		return nil, deleteErr
	}
	// return obj ...
	return &pb.EmptyObj{}, nil
}
